package com.xkdx.guangguang.fragment.myinfomation;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.xkdx.guangguang.fragment.my.setup.ExchangeListModule.MyExchange;
import com.xkdx.guangguang.module.network.AbsModule;
import com.xkdx.guangguang.shareclass.InfoManager;

public class InfoSelfModule extends AbsModule {

	public List<InfoManager> infoSelfManagerList;
	private JSONObject object; 

	@Override
	public void parseData() throws Exception {
		backJson = (JSONArray) result;
		infoSelfManagerList = new ArrayList<InfoManager>();
		try {
			object = (JSONObject) backJson.get(0);
			infoSelfManagerList =parserInfo(object);
		} catch (Exception e) {
			throw e;
		}
	}

	private List<InfoManager> parserInfo(JSONObject obj) throws Exception {

		 List<InfoManager> list = new ArrayList<InfoManager>();
		if (obj == null) {
			return null;
		}
		JSONObject object  = obj.getJSONObject("DetailInfo");
		if (!object.getString("StatusCode").equals("1")) {
			return list;
		} else {
			try {
				JSONArray stut = (JSONArray) object.get("DetailInfo");
				if (!stut.equals("") && stut.length() > 0) {
					for (int j = 0; j < stut.length(); j++) {
						JSONObject pic = (JSONObject) stut.opt(j);
						InfoManager order = new InfoManager();
						order.setId(pic.getString("ID"));
						order.setMessage(pic.getString("Msg"));
						order.setObjectType(pic.getString("ObjectType"));
						order.setObjectID(pic.getString("ObjectID"));
						order.setSendTime(pic.getString("SendTIme"));
						order.setTitle(pic.getString("Title"));
						list.add(order);
					}
					return list;
				}

			} catch (Exception e) {
				throw e;
			}
		}
		return list;
	}
}
